import { S } from '../../s';
import { IPSAppCounterRef } from '../../app/control/ipsapp-counter-ref';
import { PSAjaxControlImpl } from '../psajax-control-impl';
import { IPSLayout } from '../layout/ipslayout';
import { IPSAppMenu } from './ipsapp-menu';
import { IPSAppMenuItem } from './ipsapp-menu-item';

export class PSAppMenuImpl extends PSAjaxControlImpl implements IPSAppMenu {
  get appMenuStyle():
    | 'ICONVIEW'
    | 'LISTVIEW'
    | 'SWIPERVIEW'
    | 'LISTVIEW2'
    | 'LISTVIEW3'
    | 'LISTVIEW4'
    | 'EXTVIEW1'
    | 'EXTVIEW2'
    | 'EXTVIEW3'
    | 'EXTVIEW4'
    | 'EXTVIEW5'
    | 'USER'
    | 'USER2' {
    return this.M.appMenuStyle;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get layoutMode():
    | 'TABLE'
    | 'TABLE_12COL'
    | 'TABLE_24COL'
    | 'FLEX'
    | 'BORDER'
    | 'ABSOLUTE' {
    return this.M.layoutMode;
  }

  protected psappcounterref: IPSAppCounterRef;
  getPSAppCounterRef(): IPSAppCounterRef | null {
    return (
      this.psappcounterref ||
      (this.psappcounterref = this.fillObjectModel(
        S._9d,
        this.M.getPSAppCounterRef,
        S._2a9,
      ) as IPSAppCounterRef)
    );
  }

  protected psappmenuitems: IPSAppMenuItem[];
  getPSAppMenuItems(): IPSAppMenuItem[] | null {
    return (
      this.psappmenuitems ||
      (this.psappmenuitems = this.fillChildListModel(
        this.M.getPSAppMenuItems,
        S._da,
      ) as IPSAppMenuItem[])
    );
  }

  findPSAppMenuItem(objKey: any): IPSAppMenuItem | null {
    return this.getPSModel5(
      S._da,
      this.getPSAppMenuItems(),
      objKey,
    ) as IPSAppMenuItem;
  }

  protected pslayout: IPSLayout;
  getPSLayout(): IPSLayout | null {
    return (
      this.pslayout ||
      (this.pslayout = this.fillObjectModel(
        S._298,
        this.M.getPSLayout,
        S._2e8,
      ) as IPSLayout)
    );
  }

  get enableCustomize(): boolean {
    return this.M.enableCustomize;
  }
  get cls(): string {
    return 'PSAppMenuImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._219 || cls == S._ae || cls == S._21a) return true;
    return super.instanceof(cls);
  }
}
